package com.central.player.dao;

import com.central.player.model.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface PlayerDao {

    int count(Map<String, Object> params);

    List<PlayerBase> findList(Map<String, Object> params);

    @Select("SELECT p.playerId,p.nickName,p.sex,p.state,bag.money,bag.diamond,f.lastTime,f.pvpCount,f.pvpGrade,f.pvpWin,f.pveGrade,e.dianShu,e.elementsJson,s.debris,s.fightSkill,s.skillLevelJson ,pl.phone FROM bsdld.player p,bsdld.playerbag bag,bsdld.fightinfo f,bsdld.playerelement e,bsdld.playerskill s, login.playerlogin pl, bsdld.account a WHERE p.playerId = bag.playerId AND f.playerId = e.playerId AND p.playerId = s.playerId AND p.playerId = e.playerId AND pl.uid = a.uid AND a.id = p.playerId AND p.playerId = #{playerId}")
    List<PlayerDetailsDO> playerDetailed(Long playerId);

    @Select("SELECT ISNULL(phone) guest, count(*) count FROM login.playerlogin GROUP BY ISNULL(phone)")
    List<Guest> listGuest();

    @Select("SELECT SUM(register) registerCountToday,SUM(login) loginCountToday FROM operate_record WHERE TO_DAYS(startTime) = TO_DAYS(NOW())")
    RegisterAndLogin countLoginToday();

    @Select("SELECT ip,port FROM tongji.urlconfig WHERE type = #{type}")
    HallUrl getloginUrl(@Param("type") String login);

    @Select("SELECT SUM(total) total FROM bsdld.charge")
    Long countAllRecharge();

    @Select("SELECT SUM(dayCharge) todayRechargeMoney,count(*) todayRechargeNum FROM bsdld.charge WHERE TO_DAYS(lastChargeTime) = TO_DAYS(NOW())")
    CountRechargeDO countTodayRecharge();
}